package com.plian.system.controller.mt.mtgroup;

import com.plian.Tools.base.BaseController;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.mt.mtgroup.MTGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "api/mtgroup")
public class MTGroupController extends BaseController {
    @Autowired
    MTGroupService mTGroupService;

    /**
     * 新增
     *
     * @param pd
     * @return
     */
    @PostMapping(value = "/save")
    public ObjResult save(@RequestBody PageData pd) {
        return mTGroupService.save(pd);
    }

    /**
     * 修改
     *
     * @param pd
     * @return
     */
    @PostMapping(value = "/edit")
    public ObjResult edit(@RequestBody PageData pd) {
        return mTGroupService.edit(pd);
    }

    /**
     * 根据id查询,详情页
     *
     * @param pd
     * @return
     */
    @PostMapping(value = "/detail")
    public ObjResult detail(@RequestBody PageData pd) {
        return mTGroupService.findbyid(pd);
    }

    /**
     * 查询列表
     *
     * @return
     */
    @PostMapping(value = "/list")
    public ListResult list(@RequestBody PageData pd) {
        return mTGroupService.list(pd);
    }

    /**
     * 删除
     *
     * @param pd
     * @return
     */
    @PostMapping(value = "/delete")
    public ObjResult del_ids(@RequestBody PageData pd) {
        return mTGroupService.delete((List<String>) pd.get("ids"));
    }

    @PostMapping(value = "/unit")
    public ListResult unit () {
        return mTGroupService.unit();
    }
}
